﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ReadWriteIsolate.DB;
using ReadWriteIsolate.Model;

namespace ReadWriteIsolate.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TestController : Controller
    {
        private readonly SQLHelper _sqlHeper;
        public TestController(SQLHelper sqlHeper)
        {
            _sqlHeper = sqlHeper;
        }

        public async Task<string> ShowTest()
        {
            //Users userModel = _sqlHeper.Find<Users>(1);

            for (int i = 0; i < 100; i++)
            {
                Users userModel = _sqlHeper.Find<Users>(1);
                Thread.Sleep(100);
            }

            //string sql = "insert into users (username) values (@username)";
            //await _sqlHeper.Insert(sql, new SqlParameter("@username", userModel.UserName + "1234"));

            return "Welcome!";
        }
    }
}